/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vadung.contragame2d;

import javax.microedition.lcdui.Graphics;

/**
 *
 * @author dung.voanh
 */
public class MyBullet extends MyActor{
    private MyActor m_actorOwner;
    private int m_iDetalX;
    private int m_iDetalY;

    public void SetFlyDelta(int deltaX, int deltaY){
        m_iDetalX = deltaX;
        m_iDetalY = deltaY;
    }
    
    public MyActor GetOwner() {
        return m_actorOwner;
    }
        
    public MyBullet(MyActor actorOwner, String[] astrSpriteName) {
        super(astrSpriteName);
        this.m_actorOwner = actorOwner;
        Init();
    }

    public MyBullet(MyActor actorOwner, int[] aiSpriteID) {
        super(aiSpriteID);
        this.m_actorOwner = actorOwner;
        Init();
    }
    
    private void Init(){
        m_iDetalX = 6;
        m_iDetalY = 6;        
    }          

    public void Update() {
        super.Update();
        if(m_isDie){
            return;
        }
        
        switch(m_state){
            case DEFINE.ACTOR_STATE_MOVE_LEFT :
                MoveOnMap(-m_iDetalX, 0);
                break;
                
            case DEFINE.ACTOR_STATE_MOVE_RIGHT :
                MoveOnMap(m_iDetalX, 0);
                break;
                
            case DEFINE.ACTOR_STATE_UP :
                MoveOnMap(0, -m_iDetalY);
                break;
                
            case DEFINE.ACTOR_STATE_DOWN :
                MoveOnMap(0, m_iDetalY);
                break;    
                
            case DEFINE.ACTOR_STATE_MOVE_LEFT_UP :
                MoveOnMap(-m_iDetalX, -m_iDetalY);
                break;
                
                
            case DEFINE.ACTOR_STATE_MOVE_LEFT_DOWN :
                MoveOnMap(-m_iDetalX, m_iDetalY);
                break;
                
            case DEFINE.ACTOR_STATE_MOVE_RIGHT_UP :
                MoveOnMap(m_iDetalX, -m_iDetalY);
                break;
                
            case DEFINE.ACTOR_STATE_MOVE_RIGHT_DOWN :
                MoveOnMap(m_iDetalX, m_iDetalY);
                break;    
                
            default:
                MoveOnMap(m_iDetalX, 0);
                break;  
        }
        
        this.GetCurrentSpriteAction().NextFrame();
    }

    public void Render(Graphics g) {
        super.Render(g); //To change body of generated methods, choose Tools | Templates.
    }    
    
}
